
<template>
  <p>发送数据源的主键给后端创建task</p>
  <div class="smart-table-operate">
    <a-button @click="sendPrimaryKey(1)" type="link">
      <template #icon>
        <PlusOutlined />
      </template>
      创建任务
    </a-button>
  </div>
  <div class="smart-table-operate">
    <p>用于代码显示时的测试</p>
    <a-button @click="sendTaskId(3)" type="link">
      <template #icon>
        <PlusOutlined />
      </template>
      生成SQL
    </a-button>
  </div>
</template>
<script setup>
import message from "ant-design-vue/lib/message";
import {datataskApi} from "/src/api/business/super-computer/datatask/datatask-api.js";
import {smartSentry} from "/src/lib/smart-sentry.js";

  function sendPrimaryKey(primaryKey){
    if (primaryKey === null){
      message.error("数据源Id为空")
      return;
    }
    try {
      datataskApi.addTask(primaryKey);
      message.success("任务添加成功, 请在传输任务管理中查看")
    }catch (e) {
      message.error("信息发送失败")
      smartSentry.captureError(e)
    }
  }
  function sendTaskId(taskId){
    if (taskId === null){
      message.error("数据源Id为空")
      return;
    }
    try {
      datataskApi.getSQL(taskId);
      message.success("生成成功")
    }catch (e) {
      message.error("信息发送失败")
      smartSentry.captureError(e)
    }
  }
</script>
<style scoped lang="less">

</style>